package org.jeecg.modules.simulator.model.train.manager.trainmanager;

import org.jeecg.modules.simulator.model.MetroTrain;
import org.jeecg.modules.simulator.model.train.action.ActionRecordersStatus;
import org.jeecg.modules.simulator.model.train.action.TrainActionRecorders;
import org.jeecg.modules.simulator.rooter.TrainManager;

import java.time.LocalTime;

/**
 * @program: simulator-b20240918
 * @description:
 * @author: renzhg
 * @create: 2024-10-04 13:27
 **/
public class SucceedState  implements TrainState{

    @Override
    public void handle(TrainManager trainManager, String key, MetroTrain train, String now) {
        try {
            TrainActionRecorders trainActionRecorders = trainManager.getTrainActionRdsManager().getTrainActionRecordersMap().get(key);
            if(trainActionRecorders.moveNext()){
                trainManager.dispatchTimeTableActionRecorders(key, train, now);
            }else{
                trainActionRecorders.setStatus(ActionRecordersStatus.end);
            }


        } catch (Exception e) {
            System.err.println("Error dispatching timetable action recorders for train " + train.getTrainId() + ": " + e.getMessage());
        }
    }
}
